package com.knowif.backend.service;

import com.github.pagehelper.PageHelper;
import com.knowif.pojo.School;
import com.knowif.pojo.SchoolExample;
import com.knowif.service.School_service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：Xh
 * @date ：Created in 2019/6/5 0005 20:58
 */
@Service
public class SchoolService {

    @Autowired
    private School_service school_service;

    /**
     * 条件查询school
     * @param schoolExample
     * @return
     */
    public List<School> selectSchool(SchoolExample schoolExample){
        return school_service.selectSchool(schoolExample);
    }

    /**
     * 条件查询school
     * @param schoolExample
     * @param pageable 是否需要分页
     * @return
     */
    public List<School> selectSchool(SchoolExample schoolExample, boolean pageable){
        if(! pageable){
            PageHelper.clearPage();
        }
        return school_service.selectSchool(schoolExample);
    }

    /**
     * 保存school
     * @return
     */
    public boolean saveSchool(School school){
        int i = school_service.saveSchool(school);
        if(i == 0){
            return false;
        }
        return true;
    }

    /**
     * 保存school
     * @return
     */
    public boolean updateSchoolNotNull(School school){
        int i = school_service.updateSchoolNotNull(school);
        if(i == 0){
            return false;
        }
        return true;
    }

    /**
     * 保存school
     * @return
     */
    public boolean updateSchool(School school){
        int i = school_service.updateSchool(school);
        if(i == 0){
            return false;
        }
        return true;
    }

    /**
     * 删除school
     * @return
     */
    public boolean deleteSchool(int schoolId){
        int i = school_service.deleteSchool(schoolId);
        if(i == 0){
            return false;
        }
        return true;
    }
}
